﻿<%-- 
    Document   : newjsp
    Created on : Sep 19, 2012, 10:23:59 PM
    Author     : Odotube
--%>

<%@page import="thitracnghiem.GiaoVien"%>
<%@page import="java.util.ArrayList"%>
<%@page import="thitracnghiem.MonThi"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
       <!--- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">xoa --->
        <title>JSP Page</title>
    </head>
    <body>
        <%@include file="/menugv.html" %>
        <%

            GiaoVien gv = (GiaoVien) request.getSession().getAttribute("gv");

            if (gv == null) {
             response.sendError(403);
             }
        %>
        <form action="/ThiTracNghiem/XuLy" method="post">
            <%
                String s1 = request.getParameter("tb");
                if (s1 == null) {
                    s1 = "";
                }
                String s2 = (String) request.getSession().getAttribute("monthithemcauhoi");
                if (s2 == null) {
                    MonThi.Open();
                    ArrayList<MonThi> dsMonThi = MonThi.getDSMonThi(gv.getPhanQuyenMon());
                    MonThi.Close();
                    s1 += "Mon: <select name=mamonthi>";
                    for (int i = 0; i < dsMonThi.size(); i++) {
                        s1 += "<option value='" + dsMonThi.get(i).getMaMonThi() + "'>" + dsMonThi.get(i).getTenMonThi();
                    }
                    s1 += "</select>";
                } else {
                    MonThi.Open();
                    ArrayList<MonThi> dsMonThi = MonThi.getDSMonThi();
                    MonThi.Close();
                    s1 += "Mon: <select name=mamonthi>";
                    for (int i = 0; i < dsMonThi.size(); i++) {
                        if (!s2.equals(dsMonThi.get(i).getMaMonThi())) {
                            s1 += "<option value='" + dsMonThi.get(i).getMaMonThi() + "'>" + dsMonThi.get(i).getTenMonThi();
                        } else {
                            s1 += "<option value='" + dsMonThi.get(i).getMaMonThi() + "'selected>" + dsMonThi.get(i).getTenMonThi();
                        }
                    }
                    s1 += "</select></font>";
                }
            %>
            <p><font face="Tahoma"><%=s1%></font></p>
            <p><font face="Tahoma">Câu hỏi: <textarea name="cauhoi" rows="5" cols="60"></textarea></font></p>
            <p><font face="Tahoma">Trả lời: <textarea name="cautraloi" rows="5" cols="60"></textarea></font></p>
            <p>Đáp án: <input type="text" name="dapan"></p>
            <input type="hidden" name="yc" value="themcauhoi">
            <input type="submit" value="Them">
        </form>
    </body>
</html>
